package website.digitalocean.chapter4;

import java.util.Date;

/**
 * @author: longhc@citycloud.com.cn
 * @since: 2023/2/13 16:29
 * @version: 1.0
 */
public class User {
    private Long id;
    private String name;
    private Integer age;
    private String tel;
    private Date createTime;
    private Date updateTime;

    public User(Build build) {
        this.id = build.id;
        this.name = build.name;
        this.age = build.age;
        this.tel = build.tel;
        this.createTime = build.createTime;
        this.updateTime = build.updateTime;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", tel='" + tel + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }

    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public Integer getAge() {
        return age;
    }

    public String getTel() {
        return tel;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }


    public static class Build {
        private Long id;
        private String name;
        private Integer age;
        private String tel;
        private Date createTime;
        private Date updateTime;

        public Build(String name) {
            this.name = name;
        }

        public Build setId(Long id) {
            this.id = id;
            return this;
        }

        public Build setAge(Integer age) {
            this.age = age;
            return this;
        }

        public Build setTel(String tel) {
            this.tel = tel;
            return this;
        }

        public Build setCreateTime(Date createTime) {
            this.createTime = createTime;
            return this;
        }

        public Build setUpdateTime(Date updateTime) {
            this.updateTime = updateTime;
            return this;
        }

        public User build() {
            return new User(this);
        }
    }
}
